<script setup>
import { ref } from 'vue'
import { userInfoService, userInfoUpdateService } from '@/api/user.js'
import { ElMessage, ElMessageBox } from 'element-plus'
const info = ref({
    id: 0,
    userName: '',
    nickName: '',
    email: ''
})
//获取个人信息
const getUserInfo = async () => {
    let result = await userInfoService();
    info.value = result.data;
}
getUserInfo();
const rules = {
    id: [
        { required: true, },
    ],
    name: [
        { required: true, },
    ],
    age: [
        { required: true, },
    ],
    isManager: [
        { required: true, },
    ],
    phoneNumber: [
        { required: true, },
    ],
    enrollmentTime: [
        { required: true, },
    ],
    majorName: [
        { required: true, },
    ],

}
const userInfoUpdate = async () => {
    let result = await userInfoUpdateService(info.value);
    if (result.code == 0) {
        ElMessage.success("修改成功,刷新页面生效");
    }
    else {
        ElMessage.error(result.message ? result.message : "修改失败");
    }
}
</script>
<template>
    <el-card class="page-container">
        <template #header>
            <div class="header">
                <span>用户基本信息</span>
            </div>
        </template>
        <el-row>
            <el-col :span="6">
                <el-form :model="info" :rules="rules" label-width="100px" size="large">
                    <el-form-item label="账号" prop="account">
                        <el-input v-model="info.account" disabled></el-input>
                    </el-form-item>
                    <el-form-item label="姓名" prop="name">
                        <el-input v-model="info.name" disabled></el-input>
                    </el-form-item>
                </el-form>
            </el-col>
            <el-col :span="6">
                <el-form :model="info" :rules="rules" label-width="70px" size="large">
                    <el-form-item label="性别" prop="sex">
                        <el-input v-model="info.sex" disabled></el-input>
                    </el-form-item>
                    <el-form-item label="手机号" prop="phone">
                        <el-input v-model="info.phone" disabled></el-input>
                    </el-form-item>
                </el-form>
            </el-col>
            <el-col :span="6">
                <el-form :model="info" :rules="rules" label-width="130px" size="large">
                    <el-form-item label="生日" prop="birthday">
                        <el-input v-model="info.birthday" disabled></el-input>
                    </el-form-item>
                    <el-form-item label="备注" prop="comment">
                        <el-input v-model="info.comment" disabled></el-input>
                    </el-form-item>
                </el-form>
            </el-col>
            <el-col :span="6">
                <el-form :model="info" :rules="rules" label-width="100px" size="large">
                    <el-form-item label="角色" prop="type">
                        <el-input v-model="info.type" disabled></el-input>
                    </el-form-item>
                </el-form>
                <el-form :model="info" :rules="rules" label-width="100px" size="large">
                    <el-form-item label="所属片区" prop="areaname">
                        <el-input v-model="info.areaname" disabled></el-input>
                    </el-form-item>
                </el-form>
            </el-col>

        </el-row>
    </el-card>
</template>